package cn.itcast.nems.base.web.util;

import cn.itcast.nems.base.dto.ClazzQueryDTO;
import cn.itcast.nems.base.web.vo.ClazzQueryVO;
import org.apache.commons.lang3.StringUtils;
import org.springframework.lang.NonNull;

import java.util.List;

/**
 * 班级工具类
 *
 * @author ChangLu.Gao
 * @version v1.0
 * @program nems-server
 * @description
 * @date 2023/11/14 17:26
 */
public class ClazzWebUtil {

    /**
     * 请求参数转化后用于接口传递
     *
     * @param source 源数据
     * @return 目标数据
     */
    public static ClazzQueryDTO convert(@NonNull ClazzQueryVO source) {
        ClazzQueryDTO target = new ClazzQueryDTO();
        if (StringUtils.isNotBlank(source.getClassId())) {
            target.setClassIds(List.of(Integer.valueOf(source.getClassId())));
        }
        target.setClassName(source.getClassName());
        target.setClassTypeId(source.getClassTypeId());
        target.setSchoolId(source.getSchoolId());
        target.setSubjectId(source.getSubjectId());
        target.setTeachingModel(source.getTeachingModel());
        target.setExcludeSubjectIds(source.getExcludeSubjectIds());
        target.setUpgradeable(source.getUpgradeable());
        target.setIncludeWait(source.getIncludeWait());
        target.setIncludeWaitDeleted(source.getIncludeWaitDeleted());
        target.setMinStartDate(source.getMinStartDate());
        target.setMaxStartDate(source.getMaxStartDate());
        target.setDelayFlag(source.getDelayFlag());
        target.setSuspensionFlag(source.getSuspensionFlag());
        target.setStartFlag(source.getStartFlag());
        target.setLockFlag(source.getLockFlag());
        target.setCurrentMonthGraduationFlag(source.getCurrentMonthGraduationFlag());
        target.setTransfer(source.getTransfer());
        target.setEnrolFlag(source.getEnrolFlag());
        target.setNewFlag(source.getNewFlag());
        target.setExcludeFlag(source.getExcludeFlag());
        return target;
    }
}
